<?php

namespace App\Repository\Repositories;

use App\Repository\Repositories\Interfaces\AdvertisementRepository;
use App\Repository\Models\Advertisement;

/**
 * Class AdvertisementRepositoryEloquent.
 *
 * @package namespace App\Repository\Repositories;
 */
class AdvertisementRepositoryEloquent extends BaseRepository implements AdvertisementRepository
{
    /**
     * 搜索
     * @var array
     */
    protected $fieldSearchable = ['position'];

    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
        return Advertisement::class;
    }


    public function indexGetAdv(){

        $data['adv_o'] = $this->query()->where(['audit'=>1,'position'=>1])->orderBy('sort','desc')->get()->toArray();
        $data['adv_t'] = $this->query()->where(['audit'=>1,'position'=>2])->orderBy('sort','desc')->limit(2)->get()->toArray();
        $data['adv_th'] = $this->query()->where(['audit'=>1,'position'=>3])->orderBy('sort','desc')->get()->toArray();
        $data['adv_f'] = $this->query()->where(['audit'=>1,'position'=>4])->orderBy('sort','desc')->get()->toArray();
        $data['adv_fi'] = $this->query()->where(['audit'=>1,'position'=>5])->orderBy('sort','desc')->get()->toArray();
        $data['adv_s'] = $this->query()->where(['audit'=>1,'position'=>6])->orderBy('sort','desc')->get()->toArray();

        return $data;
    }



    public function shopGetAdv(){

        $data['adv_o'] = $this->query()->where(['audit'=>1,'position'=>7])->orderBy('sort','desc')->get()->toArray();
        $data['adv_t'] = $this->query()->where(['audit'=>1,'position'=>8])->orderBy('sort','desc')->limit(3)->get()->toArray();
        $data['adv_th'] = $this->query()->where(['audit'=>1,'position'=>9])->orderBy('sort','desc')->get()->toArray();

        return $data;
    }




}
